<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<%@ include file="inc/head.jsp" %>        
    
<title>添加用户</title>
</head>
<body>  
<!--Begin Header Begin-->
	
<%@ include file="inc/head2.jsp" %>	

<%@ include file="inc/shopping.jsp" %>

<!--End Header End--> 
	<div class="i_bg bg_color">
	
    <div class="m_content">
        
<%@ include file="inc/m_left.jsp" %>

	<div class="m_right" id="content">
		<div class="mem_tit">
			添加用户
		</div>
		<br>
		<form action="${pageContext.request.contextPath}/InsertUserInfoServlet" method="post" id="userAdd"">
			<table border="0" class="add_tab" style="width:930px;" cellspacing="0" cellpadding="0">
				<tbody>
					<tr>
						<td width="135" align="right">用户姓名</td>
						<td colspan="3" style="font-family:'宋体';">
							<input type="text" value="" class="add_ipt" name="loginName">
							<input type="hidden" value="${sessionScope.userId}" name="id">
						</td>
					</tr>
					<tr>
						<td width="135" align="right">真实姓名</td>
						<td>
							<input type="text" value="" class="add_ipt" name="userName">
						</td>
					</tr>
					
					<tr>
						<td width="135" align="right">性别</td>
						<td>
							<select name="sex">
								<option value="-1">请选择</option>
								<option value="1">男</option>
								<option value="0">女</option>
							</select>
						</td>
					</tr>
	
					<tr>
						<td width="135" align="right">密码</td>
						<td>
							<input type="password" value="" class="add_ipt" name="password">
						</td>
					</tr>
					<tr>
						<td width="135" align="right">确认密码</td>
						<td>
							<input type="password" value="" class="add_ipt" name="repPassword">
						</td>
					</tr>
	
					<tr>
						<td width="135" align="right">身份证号</td>
						<td>
							<input type="text" value="" class="add_ipt" name="identityCode" id="identityCode">
						</td>
					</tr>
					<tr>
						<td width="135" align="right">电子邮箱</td>
						<td>
							<input type="text" value="" class="add_ipt" name="email" id="email">
						</td>
					</tr>
					<tr>
						<td width="135" align="right">手机号码</td>
						<td>
							<input type="text" value="" class="add_ipt" name="mobile" id="mobile">
						</td>
					</tr>
					<tr>
						<td width="135" align="right">用户类型</td>
						<td>
							<select name="type">
								<option value="-1">请选择</option>
								<option value="1">管理员</option>
								<option value="0">普通用户</option>
							</select>
						</td>
					</tr>
					<tr>
						<td></td>
						<td>
	
							<input type="submit" value="添加用户" class="s_btn" onclick="addUser();">
	
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div> </div>
</div>
	
<%@ include file="inc/footer.jsp" %>
	
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
	$("#userAdd").on("submit",function(){
		var loginName = $("input[name='loginName']").val();
		var userName = $("input[name='userName']").val();
		var sex = $("select[name='sex']").val();
		var password = $("input[name='password']").val();
		var repPassword = $("input[name='repPassword']").val();
		var identityCode = $("input[name='identityCode']").val();
		
		var email = $("input[name='email']").val();
		var mobile = $("input[name='mobile']").val();
		var type = $("select[name='type']").val();
		if(loginName ==""){
			alert("用户姓名不能为空!");
			return false;
		}
		
		if(userName ==""){
			alert("真实姓名不能为空!");
			return false;
		}
		
		if(sex =="-1"){
			alert("性别必须选择!");
			return false;
		}
		
		if(password ==""){
			alert("密码不能为空!");
			return false;
		}
		
		if(repPassword ==""){
			alert("确认密码不能为空!");
			return false;
		}
		if(!password.equals(repPassword)){
			alert("两次密码不一致!");
			return false;
		}
		if(identityCode ==""){
			alert("身份证号不能为空!");
			return false;
		}
		
		if(email ==""){
			alert("电子邮箱不能为空!");
			return false;
		}
		if(mobile ==""){
			alert("手机号码不能为空!");
			return false;
		}
		if(department =="-1"){
			alert("用户类型必须选择!");
			return false;
		}
	});
})
</script>
</body>

</html>
